package com.ydd.controller.admin;

import com.ydd.dto.LinkDTO;
import com.ydd.dto.LinkPageQueryDTO;
import com.ydd.result.PageResult;
import com.ydd.result.Result;
import com.ydd.service.YddLinkService;
import com.ydd.vo.LinkVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description TODO
 * @Author fang
 * @Date 2023-05-29 16:48
 */
@Api(tags = "广告管理-友情链接管理")
@RestController
@RequestMapping("/admin/ydd_link")
@Slf4j
public class YddLinkController {
    @Autowired
    YddLinkService yddLinkService;
    @GetMapping("/rowInfo")
    @ApiOperation("链接详情")
    public Result linkRowinfo(Long id){
        log.info("链接详情:{}",id);
        LinkVO linkVO=yddLinkService.linkRowinfo(id);
        return Result.success(linkVO);
    }
    @PostMapping("/update")
    @ApiOperation("链接修改")
    public Result updateLink(@RequestBody LinkDTO linkDTO){
        log.info("链接修改:{}",linkDTO);
        yddLinkService.updateLink(linkDTO);
        return Result.success();
    }
    @GetMapping("/del")
    @ApiOperation("链接删除")
    public Result deleteLink(Long id){
        log.info("链接删除:{}",id);
        yddLinkService.deleteLink(id);
        return Result.success();
    }
    @PostMapping("/add")
    @ApiOperation("链接添加")
    public Result addLink(@RequestBody LinkDTO linkDTO){
        log.info("链接添加:{}",linkDTO);
        yddLinkService.addLink(linkDTO);
        return Result.success();
    }
    @GetMapping("/list")
    @ApiOperation("链接列表")
    public Result<PageResult<LinkVO>>listLink(LinkPageQueryDTO linkPageQueryDTO){
    log.info("链接列表:{}",linkPageQueryDTO);
    PageResult<LinkVO> pageResult=yddLinkService.listLink(linkPageQueryDTO);
    return Result.success(pageResult);


    }

}
